package recyclerview.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lib.recyclyeviewmodule.R;


/**
 * Created by Zmm on 2016/11/17.
 */

public class LoadMoreFooter extends RelativeLayout {
    TextView tv_load_fail;
    ProgressBar pb;
    View root;
    public static final int FAIL=-1;
    public static final int NOMAL =0;
    public static final int LOADING=1;
    public static final int END =2;
    public int mState;
    public LoadMoreFooter(Context context) {
        this(context,null);
    }

    public LoadMoreFooter(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public LoadMoreFooter(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    private void initView() {
        View footer = LayoutInflater.from(getContext()).inflate(R.layout.item_loadmore_footer, this);
        root = footer.findViewById(R.id.rl_footer_all);
        tv_load_fail= (TextView) footer.findViewById(R.id.tv_loadmore_fail);
        pb= (ProgressBar) footer.findViewById(R.id.pb_loadmore);
    }
    public void  setState(int state){
           mState=state;
        switch (state){
            case NOMAL:
                tv_load_fail.setVisibility(View.GONE);
         //       tv_end.setVisibility(View.GONE);
                pb.setVisibility(View.GONE);
                break;
            case LOADING:
                pb.setVisibility(View.VISIBLE);
                tv_load_fail.setVisibility(View.GONE);
        //        tv_end.setVisibility(View.GONE);
                break;
            case END:
         //       tv_end.setVisibility(View.VISIBLE);
                tv_load_fail.setVisibility(View.VISIBLE);
                pb.setVisibility(View.GONE);
                tv_load_fail.setText(R.string.load_more_footer_end);
                break;
            case FAIL:
                pb.setVisibility(View.GONE);
 //               tv_end.setVisibility(View.GONE);
                tv_load_fail.setVisibility(View.VISIBLE);
                tv_load_fail.setText(R.string.load_more_footer_fail);
                break;
        }
    }
    public void toDay(){

    }
    public void toNight(){

    }
    public int getmState(){
        return mState;
    }
}
